package freeCellDataStructures;

import java.util.Stack;
import freeCellBackend.Card;


public class Foundation{
	private Stack<Card> foundation;
	
	public Foundation(){
		foundation = new Stack<Card>();
	}
	public boolean add(Card c){
		if(foundation.isEmpty()){
			if (c.getValue() == 1) {
				foundation.push(c);
				return true;
			}
			return false;
		} else if((foundation.peek().getSuite() == c.getSuite()) && (foundation.peek().getValue() + 1 == c.getValue())){
			foundation.push(c);
			return true;
		}
		return false;
	}
	public Card get() {
		if(foundation.isEmpty()) {
			return null;
		} else {
			return foundation.peek();
		}
	}
}
